import axios from '@/libs/api.request'

export const addNamespace = (data) => {
  return axios.request({
    url: 'production/namespaced/',
    data,
    method: 'post'
  })
}

export const deleteNamespace = (params) => {
  return axios.request({
    url: 'production/namespaced/',
    params,
    method: 'delete'
  })
}

export const namespaceList = (params) => {
  return axios.request({
    url: 'production/namespaced/',
    params,
    method: 'get'
  })
}

export const podsList = (params) => {
  return axios.request({
    url: 'production/pods/',
    params,
    method: 'get'
  })
}

export const podsAllSearch = (cloud_name, namespaceName, deploymentName) => {
  const params = {
    'cloud_name': cloud_name,
    'namespace_name': namespaceName,
    'searchName': deploymentName
  }
  return axios.request({
    url: 'production/pods/',
    params,
    method: 'get'
  })
}

export const deploymentList = (params) => {
  return axios.request({
    url: 'production/deployment/',
    params,
    method: 'get'
  })
}

export const deploymentCreate = (data) => {
  return axios.request({
    url: 'production/deployment/',
    data,
    method: 'post'
  })
}

export const deploymentDelete = (params) => {
  return axios.request({
    url: 'production/deployment/',
    params,
    method: 'delete'
  })
}

export const deploymentAllSearch = (cloud_name, namespaceName, deploymentName) => {
  const params = {
    'cloud_name': cloud_name,
    'namespace_name': namespaceName,
    'searchName': deploymentName
  }
  return axios.request({
    url: 'production/deployment/',
    params,
    method: 'get'
  })
}

export const deploymentRollBackList = (params) => {
  return axios.request({
    url: 'production/roll_back_list/',
    params,
    method: 'get'
  })
}

export const deploymentRollBack = (params) => {
  return axios.request({
    url: 'production/roll_back/',
    params,
    method: 'get'
  })
}

export const deploymentUpdate = (params) => {
  return axios.request({
    url: 'production/deploy/',
    params,
    method: 'get'
  })
}

export const ingressList = (params) => {
  return axios.request({
    url: 'production/ingress/',
    params,
    method: 'get'
  })
}

export const ingressDelete = (params) => {
  return axios.request({
    url: 'production/ingress/',
    params,
    method: 'delete'
  })
}

export const ingressCreate = (data) => {
  return axios.request({
    url: 'production/ingress/',
    data,
    method: 'post'
  })
}

export const serviceList = (params) => {
  return axios.request({
    url: 'production/service/',
    params,
    method: 'get'
  })
}

export const serviceCreate = (data) => {
  return axios.request({
    url: 'production/service/',
    data,
    method: 'post'
  })
}

export const serviceDelete = (params) => {
  return axios.request({
    url: 'production/service/',
    params,
    method: 'delete'
  })
}
